<%@page import="java.util.Arrays"%>
<%@page import="java.util.HashSet"%>
<%@page import="java.util.Set"%>
<%@page import="com.google.common.base.Joiner"%>
<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="stripes" uri="http://stripes.sourceforge.net/stripes.tld" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ page trimDirectiveWhitespaces="true" %>

<c:if test="${actionBean.erroneous}">

    <%
        String[] errorparams = Arrays.copyOf(request.getParameterValues("errorfragment"), request.getParameterValues("errorfragment").length);

        for (int i = 0; i < errorparams.length; i++) {
            errorparams[i] = errorparams[i].split("#")[0];
        }

        response.setHeader("Response-Fragments", Joiner.on(",").join(errorparams));
    %>

    <c:forEach var="fragment" items="${paramValues.errorfragment}">
        <jsp:include page="${fn:substringAfter(fragment, '#')}" />
    </c:forEach>

</c:if>

<c:if test="${!actionBean.erroneous}">

    <%
        String[] params = Arrays.copyOf(request.getParameterValues("fragment"), request.getParameterValues("fragment").length);

        for (int i = 0; i < params.length; i++) {
            params[i] = params[i].split("#")[0];
        }

        response.setHeader("Response-Fragments", Joiner.on(",").join(params));
    %>
    <c:forEach var="fragment" items="${paramValues.fragment}">
        <jsp:include page="${fn:substringAfter(fragment, '#')}" />
    </c:forEach>
</c:if>
